/*
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
 *
 * 
 * Copyright 2010 yura, Version 2.0 (the "License");
 *
 * you may not use this file except in compliance with the License.
 *
 * You may obtain a copy of the License at
 *
 * 
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * 
 * Unless required by applicable law or agreed to in writing, software
 *
 * distributed under the License is distributed on an "AS IS" BASIS,
 *
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *
 * See the License for the specific language governing permissions and
 *
 * limitations under the License.
 */

package org.opu.doc2db.document.datadocument;

import java.util.Collection;
import org.simpleframework.xml.Root;

/**
 *  document - main part of processing
 * 
 * @author yura
 */
@Root(name="document")
public class Document extends ParagraphList<Paragraph> {

    /**
     *  Create empty table
     */
    public Document() {
        super();
        super.dataSeparator = "\n";
    }

    /**
     *  Create document withoute paragraph identificator
     * and with data (paragraphs - data of document)
     *
     * @param rows table rows
     */
    public Document(Collection<Paragraph> paragraphs) {
        
        super("", paragraphs);
        super.dataSeparator = "\n";
    }

    /**
     *  Returns an array containing all of the elements
     * if rows list
     *
     * @return array containing all of the rows
     */
    public Paragraph[] dataToArray() {
        Object[] obj = elements.toArray();
        Paragraph[] ret = new Paragraph[obj.length];

        System.arraycopy(obj, 0, ret, 0, obj.length);

        return ret;
    }

}
